import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { STWidgetRegistry } from '@delon/abc';
import { WidgetRegistry } from '@delon/form';
import { SharedModule } from '../shared.module';
import { DBColumnFilterWidgetComponent } from './db/db-column-filter.widget';
import { DBConnectWidgetComponent } from './db/db-connect.widget';
import { STImgWidget } from './img-test.widget';
import { ImgUploadWidgetComponent } from './img-upload.widget';
import { TinymceWidget } from './tinymce.widget';

export const STWIDGET_COMPONENTS = [TinymceWidget, ImgUploadWidgetComponent, DBConnectWidgetComponent, DBColumnFilterWidgetComponent];

@NgModule({
  declarations: STWIDGET_COMPONENTS,
  imports: [SharedModule],
  exports: [...STWIDGET_COMPONENTS],
  schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class STWidgetModule {
  constructor(widgetRegistry: WidgetRegistry, stwidgetRegistry: STWidgetRegistry) {
    widgetRegistry.register(TinymceWidget.KEY, TinymceWidget);
    widgetRegistry.register(ImgUploadWidgetComponent.KEY, ImgUploadWidgetComponent);
    widgetRegistry.register(DBConnectWidgetComponent.KEY, DBConnectWidgetComponent);
    widgetRegistry.register(DBColumnFilterWidgetComponent.KEY, DBColumnFilterWidgetComponent);
    stwidgetRegistry.register(STImgWidget.KEY, STImgWidget);
  }
}
